package com.example.practice.controller;

import com.example.practice.entity.Collect;
import com.example.practice.service.CollectService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Collect)表控制层
 *
 * @author makejava
 * @since 2024-01-08 10:34:13
 */
@RestController
@RequestMapping("api/collect")
public class CollectController {
    /**
     * 服务对象
     */
    @Resource
    private CollectService collectService;

    /**
     * 通过主键查询单条数据
     *
     * @return 单条数据
     */
    @GetMapping("getCollection")
    public List<Collect> queryById(Integer uid) {
        return this.collectService.queryById(uid);
    }

    /**
     * 新增数据
     *
     * @return 新增结果
     */
    @GetMapping("insertCollection")
    public Integer add(Integer uid,Integer aid) {
        return this.collectService.insert(uid,aid);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.collectService.deleteById(id));
    }

}

